<script src="/ueditor/ueditor.config.js"></script>
<script src="/ueditor/ueditor.all.min.js"></script>
<script src="/ueditor/lang/zh-cn/zh-cn.js"></script>

<div class="content">
    <form id="add-form" class="form-horizontal nice-validator n-default n-bootstrap" role="form" data-toggle="validator" method="POST" action="" novalidate="novalidate" enctype="multipart/form-data">

        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">标题:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="title" class="form-control" name="title" value="" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">副标题:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="title2" class="form-control" name="title2" value="" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">外链地址:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="linkto" class="form-control" name="linkto" type="text">
            </div>
        </div>
        <div class="form-group" >
            <label class="control-label col-xs-12 col-sm-2">媒体类型:</label>
            <div class="col-xs-12 col-sm-8">
                <input  name="m_type"  value="0" type="radio" checked="checked" id="radio1">图片
                <input  name="m_type"  value="1" type="radio" id="radio2">视频
            </div>
        </div>
        <div class="form-group" id="imgDiv1" >
            <label class="control-label col-xs-12 col-sm-2">媒体地址:</label>
            <div class="col-xs-12 col-sm-8">
                <img src="" alt="" id="lod_pic"  width="200">
                <input id="imgurl"  name="imgurl" type="hidden">
                <button type="button" onclick="img_sub();" style="display:block;">图片上传</button>
            </div>
        </div>
        <div class="form-group" id="videoDiv2" style="display: none;">
            <label class="control-label col-xs-12 col-sm-2">媒体地址:</label>
            <div class="col-xs-12 col-sm-8">
               <input type="file" name="imgurl" accept="video/mp4"/>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">内容:</label>
            <div class="col-xs-12 col-sm-8">
                <textarea name="info"  id="info"></textarea>
            </div>
        </div>

        <div class="form-group layer-footer">
            <label class="control-label col-xs-12 col-sm-2"></label>
            <div class="col-xs-12 col-sm-8">
                <button type="button" class="btn btn-success btn-embossed" onclick="sub();">确定</button>
                <a href="/admin/product/index_img?id={$pid}" class="btn btn-default btn-embossed">返回</a>
            </div>
        </div>
    </form>

</div>
<script language="javascript" type="text/javascript" src="/assets/My97DatePicker/jquery-1.8.2.js"></script>
<script language="javascript" type="text/javascript" src="/assets/libs/fastadmin-layer/dist/layer.js"></script>


<script>
    function img_sub() {
        var tr_id=510;
        var tri_id=320;
        var p_id="lod_pic";
        var flag=0;
        var url="/add_img.php?p_id="+p_id+"&tr_id="+tr_id+"&tri_id="+tri_id+"&flag="+flag;
        //alert(url);
        layer.open({
            type: 2,
            title:"图片裁切",
            shift: 2,
            area: ['100%', '100%'],
            //shadeClose: true,
            content: [url],
            scrollbar: true ,//屏蔽浏览器滚动条
        });
    }

    function sub(){
        var title=$("#title").val();
        if(title==''){
            alert("标题不得为空");
            return;
        }
        var url=$("#lod_pic").attr("src");
        $("#imgurl").val(url);

        $("#add-form").submit();
    }

    $("input[type='radio']").click(function(){
        var id=$(this).attr("id");
       // alert(id);
       if(id=="radio1"){
           $("#imgDiv1").show();
           $("#videoDiv2").hide();
       }else if(id=="radio2"){
           $("#videoDiv2").show();
           $("#imgDiv1").hide();
       }


    })



</script>

<script type="text/javascript">
    UE.getEditor('info', {
        theme:"default", //皮肤
        lang:"zh-cn", //语言
        initialFrameWidth:1078,  //初始化编辑器宽度,默认800
        initialFrameHeight:320//  初始化编辑器高度
    });
</script>
